<template>
  <div class="container">
    <div class="result-card">
      <div class="result-header">
        <h2>测试结果：{{ route.query.result }}分</h2>
        <p>测试解析：{{ resultText }}</p>
      </div>

      <div class="result-content">
        <div class="special-notes">
          <p>本测试如同一面情绪镜子，帮助你觉察内心状态，但并非诊断工具。</p>
          <p>低分项可能提示需要关爱的领域，而非对个人的否定——脆弱恰恰是成长的起点。</p>
          <p>无论得分如何，你都可以温柔地对自己说："我正在努力，这已经很棒了。"</p>
          <p>愿你始终记得：每一种情绪都有意义，每一次求助都是勇气。</p>
        </div>
      </div>

      <div style="text-align: center;">
        <router-link to="/">
          <a href="#" class="retest-btn">再测一次</a>
        </router-link>
      </div>
    </div>
  </div>
</template>
<script setup>
import {onMounted, ref, watch} from "vue";
import {useRoute} from 'vue-router'

const route = useRoute()
const resultText = ref('')
const resultArr = [
  {min: 0, max: 29, result: '心理状态亟需专业支持，你此刻的艰难值得被认真对待，请立即拨打心理援助热线（如12355）。'},
  {min: 30, max: 49, result: '心理状态亮起黄灯，持续的情绪低落需要重视，请主动联系学校心理老师或专业机构。'},
  {min: 50, max: 69, result: '心理能量需要补给，可能存在未被解决的困扰，建议与信任的人交谈或尝试心理咨询。'},
  {min: 70, max: 89, result: '整体状态稳定，偶尔会有情绪波动，建议通过艺术表达、户外活动等方式释放压力。'},
  {min: 90, max: 100, result: '心理状态充满活力！你拥有良好的情绪调节能力与支持系统，继续保持自我关怀。'},
]

function genResult() {
  resultArr.forEach(item => {
    if (route.query.result >= item.min && route.query.result <= item.max) {
      resultText.value = item.result
    }
  })
}

onMounted(() => {
  genResult()
})

watch(() => route.query.result, () => {
  genResult()
})
</script>
<style scoped>
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

.container {
  font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
  min-height: 100vh;
  background: linear-gradient(135deg,
  var(--primary-orange),
  var(--primary-purple));
  background-size: 200% 200%;
  animation: gradientBG 12s ease infinite;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  color: var(--text-dark);
  line-height: 1.6;
  user-select: none;
}

@keyframes gradientBG {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

/* 主卡片设计 */
.result-card {
  width: 100%;
  max-width: 650px;
  background: hsla(0, 0%, 100%, 0.88);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  padding: 40px;
  box-shadow: 0 15px 35px hsla(0, 0%, 0%, 0.1),
  0 5px 15px hsla(280, 60%, 65%, 0.2);
  transform: translateY(0);
  transition: transform 0.4s ease, box-shadow 0.4s ease;
  position: relative;
  overflow: hidden;
}

.result-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 20px 40px hsla(0, 0%, 0%, 0.15),
  0 8px 20px hsla(280, 60%, 65%, 0.25);
}

/* 标题区域 */
.result-header {
  text-align: center;
  margin-bottom: 30px;
  position: relative;
}

.result-header h2 {
  font-size: 2.2rem;
  color: hsl(280, 60%, 40%);
  margin-bottom: 10px;
  font-weight: 600;
}

.result-header p {
  font-size: 1.1rem;
  color: var(--text-dark);
}

/* 内容区域 */
.result-content {
  margin-bottom: 30px;
}

.special-notes {
  border-left: 3px solid var(--primary-orange);
  padding-left: 20px;
  margin: 25px 0;
}

.special-notes p {
  position: relative;
  padding-left: 25px;
  margin-bottom: 15px;
}

.special-notes p::before {
  content: "◆";
  position: absolute;
  left: 0;
  color: var(--primary-orange);
}

/* 按钮设计 */
.retest-btn {
  display: inline-block;
  background: linear-gradient(135deg,
  hsl(0, 80%, 65%),
  hsl(0, 70%, 60%));
  color: var(--text-light);
  padding: 14px 32px;
  font-size: 1.1rem;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 4px 15px hsla(0, 60%, 60%, 0.3),
  inset 0 1px 1px hsla(0, 0%, 100%, 0.4);
  transition: all 0.3s ease;
  font-weight: 500;
  text-decoration: none;
  margin-top: 10px;
  position: relative;
  overflow: hidden;
}

.retest-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px hsla(0, 60%, 60%, 0.4),
  inset 0 1px 1px hsla(0, 0%, 100%, 0.4);
}

.retest-btn:active {
  transform: scale(0.98);
}

.retest-btn::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(
      to bottom right,
      hsla(0, 0%, 100%, 0) 45%,
      hsla(0, 0%, 100%, 0.3) 50%,
      hsla(0, 0%, 100%, 0) 55%
  );
  transform: rotate(30deg);
  animation: shine 2s infinite;
}

@keyframes shine {
  0% {
    transform: translateX(-100%) rotate(30deg);
  }
  100% {
    transform: translateX(100%) rotate(30deg);
  }
}

/* 响应式设计 */
@media (max-width: 768px) {
  .result-card {
    padding: 30px 20px;
    border-radius: 16px;
  }

  .result-header h2 {
    font-size: 1.8rem;
  }

  .result-header p {
    font-size: 1rem;
  }

  .retest-btn {
    padding: 12px 28px;
    font-size: 1rem;
  }
}
</style>